package cn.dto;

import lombok.Data;

@Data
public class Query{
    private Integer page=1;
    private Integer limit = 10;
    private Integer offset= (page - 1) * limit;//偏移量
    private String search; // 搜索关键字

    public Query(){
        super();
    }
    public Query(int page,int limit){
        super();
        this.page = page;
        this.limit = limit;
        offset= (page - 1) * limit;
    }

    public void setOffset() {
        offset = (page - 1) * limit;
    }

    public int getPages(int total){
        return (total-1)/limit+1;
    }
}
